{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-05T13:32:36.669109Z",
     "start_time": "2018-08-05T13:32:36.466915Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Fold 1\n",
      "Fold 2\n",
      "Fold 3\n",
      "Fold 4\n",
      "Fold 5\n",
      "Fold 6\n"
     ]
    }
   ],
   "source": [
    "# -*- coding: UTF-8 -*-\n",
    "\n",
    "# 执行环境 Py3.\n",
    "# 修改日期 2018/08/04\n",
    "# 交叉验证lightGBM训练\n",
    "\n",
    "import os, sys, codecs, gc\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "from tqdm import tqdm, tqdm_notebook\n",
    "from sklearn.externals.joblib import Parallel, delayed\n",
    "from sklearn.metrics import f1_score, log_loss, classification_report\n",
    "from sklearn.model_selection import StratifiedKFold\n",
    "\n",
    "# 训练集的原始标签\n",
    "train_label = pd.read_csv('../input/train_label.csv')\n",
    "\n",
    "# API的名称\n",
    "api = codecs.open('./api.csv', 'r').readlines()\n",
    "api = [x[:-1] for x in api]\n",
    "\n",
    "apidict2 = {}\n",
    "for i, apicode in enumerate(api):\n",
    "    apidict2[apicode] = 0\n",
    "\n",
    "def fidfeat_single(id, path, part):\n",
    "    if id % 100 == 0:\n",
    "        print(id)\n",
    "    \n",
    "    df = pd.read_hdf(path + str(id) + '.hdf', part)\n",
    "    \n",
    "    apidict = apidict2.copy()\n",
    "    apidict['file_id'] = id\n",
    "     \n",
    "    for rows in df['api'].value_counts().reset_index().iterrows():\n",
    "        apidict[rows[1]['index']] = rows[1]['api']\n",
    "       \n",
    "    apidict['api_count'] = df['api'].nunique()\n",
    "    apidict['tid_count'] = df['tid'].nunique()\n",
    "    \n",
    "    apidict['return_value_count'] = df['return_value'].nunique()\n",
    "    apidict['return_value=0'] = sum(df['return_value'] == 0) / df.shape[0]\n",
    "    apidict['return_value!=0'] = sum(df['return_value'] != 0) / df.shape[0]\n",
    "    apidict['return_value==1'] = sum(df['return_value'] == 1) / df.shape[0]\n",
    "    apidict['return_value=-1'] = sum(df['return_value'] == -1) / df.shape[0]\n",
    "    apidict['return_value_max'] = df['return_value'].max()\n",
    "    apidict['return_value_min'] = df['return_value'].min()\n",
    "    apidict['return_value_std'] = df['return_value'].std()\n",
    "    \n",
    "    apidict['tid_first_value'] = df.groupby('tid').first()['return_value'].mean()\n",
    "    apidict['tid_first_value!=0'] = sum(df.groupby('tid').first()['return_value'] != 0)\n",
    "    apidict['tid_last_value'] = df.groupby('tid').last()['return_value'].mean()\n",
    "    apidict['tid_last_value!=0'] = sum(df.groupby('tid').last()['return_value'] != 0)\n",
    "    \n",
    "    # Behaviour: File, Process, Memory, Register, Network, Service, Other.\n",
    "    \n",
    "    # 注册表信息，注册表修改信息\n",
    "    reg_cols = ['RegOpenKeyExW', 'RegQueryValueExW', 'RegCloseKey', 'RegOpenKeyExA', 'RegQueryValueExA',\n",
    "               'RegEnumKeyExW', 'RegQueryInfoKeyW', 'RegEnumValueW', 'RegEnumKeyW', 'RegCreateKeyExW',\n",
    "               'RegSetValueExW', 'RegEnumValueA', 'RegDeleteValueW', 'RegCreateKeyExA', 'RegEnumKeyExA',\n",
    "               'RegSetValueExA', 'RegDeleteValueA', 'RegDeleteKeyW', 'RegQueryInfoKeyA', 'RegDeleteKeyA']\n",
    "    \n",
    "    regalter_cols = ['RegCreateKeyExW', 'RegSetValueExW', 'RegDeleteValueW', 'RegCreateKeyExA',\n",
    "               'RegSetValueExA', 'RegDeleteValueA', 'RegDeleteKeyW', 'RegDeleteKeyA']\n",
    "    \n",
    "    apidict['reg_info'] = int(df[df['api'].isin(reg_cols)].shape[0] > 1)\n",
    "    apidict['reg_info_ratio'] = df[df['api'].isin(reg_cols)].shape[0] / (df.shape[0] + 1)\n",
    "    \n",
    "    apidict['reg_infoalter'] = int(df[df['api'].isin(regalter_cols)].shape[0] > 1)\n",
    "    apidict['reg_infoalter_ratio'] = df[df['api'].isin(regalter_cols)].shape[0] / (df[df['api'].isin(reg_cols)].shape[0]+1)\n",
    "    \n",
    "    # 网络信息\n",
    "    network_cols = ['InternetCrackUrlA', 'InternetSetOptionA', 'InternetGetConnectedState', 'InternetOpenW',\n",
    "                   'InternetSetStatusCallback', 'InternetConnectW', 'InternetQueryOptionA', 'InternetCloseHandle',\n",
    "                   'InternetOpenA', 'InternetConnectA', 'InternetOpenUrlA', 'InternetReadFile',\n",
    "                   'InternetGetConnectedStateExW', 'InternetGetConnectedStateExA', 'InternetWriteFile']\n",
    "    apidict['network_info'] = int(df[df['api'].isin(network_cols)].shape[0] > 1)\n",
    "    \n",
    "    # 内存信息\n",
    "    memory_cols = ['NtAllocateVirtualMemory', 'NtFreeVirtualMemory', 'NtProtectVirtualMemory', 'WriteProcessMemory',\n",
    "                  'ReadProcessMemory', 'NtReadVirtualMemory', 'CryptProtectMemory', 'CryptUnprotectMemory', 'NtWriteVirtualMemory']\n",
    "    apidict['memory_info'] = int(df[df['api'].isin(memory_cols)].shape[0] > 1)\n",
    "    \n",
    "    # 文件信息\n",
    "    file_cols = ['NtCreateFile', 'NtWriteFile', 'NtQueryAttributesFile', 'GetFileVersionInfoSizeW', 'GetFileVersionInfoW',\n",
    "                'NtSetInformationFile', 'NtDeviceIoControlFile', 'NtOpenFile', 'FindFirstFileExW', 'GetFileAttributesW',\n",
    "                'DeleteFileW', 'CopyFileA', 'SetFilePointer', 'NtReadFile', 'GetFileType', 'SetFileTime',\n",
    "                'CopyFileW', 'MoveFileWithProgressW', 'CopyFileExW', 'NtDeleteFile']\n",
    "    filealter_cols = ['NtCreateFile', 'NtWriteFile',\n",
    "                'DeleteFileW', 'CopyFileA', 'SetFilePointer', 'SetFileTime',\n",
    "                'CopyFileW', 'MoveFileWithProgressW', 'CopyFileExW', 'NtDeleteFile']\n",
    "    \n",
    "    apidict['file_info'] = int(df[df['api'].isin(file_cols)].shape[0] > 1)\n",
    "    apidict['filealter_info'] = int(df[df['api'].isin(filealter_cols)].shape[0] > 1)\n",
    "    apidict['filealter_ratio'] = apidict['filealter_info'] / (apidict['file_info'] + 1)\n",
    "    \n",
    "    # 进程信息\n",
    "    thread_cols = ['CreateThread', 'Thread32First', 'Thread32Next', 'NtResumeThread', 'NtCreateThreadEx',\n",
    "                   'NtOpenThread', 'NtTerminateThread', 'NtSuspendThread', 'NtGetContextThread'\n",
    "                   'CreateRemoteThread', 'NtQueueApcThread', 'RtlCreateUserThread', 'NtSetContextThread',\n",
    "                   'CreateRemoteThreadEx', 'NtCreateThread']\n",
    "    apidict['thread_info'] = int(df[df['api'].isin(thread_cols)].shape[0] > 1)\n",
    "    apidict['thread_ratio'] = df['api'].isin(thread_cols).iloc[-10:].sum() / 10\n",
    "    \n",
    "    # 服务信息\n",
    "    service_cols = ['OpenServiceA', 'CreateServiceA', 'StartServiceA', 'CreateServiceW', 'StartServiceW',\n",
    "                    'ControlService', 'DeleteService']\n",
    "    apidict['service_info'] = int(df[df['api'].isin(reg_cols)].shape[0] > 1)\n",
    "    \n",
    "    # DLL信息\n",
    "    dll_cols = ['LdrLoadDll', 'LdrUnloadDll', 'LdrGetDllHandle']\n",
    "    apidict['dll_info'] = int(df[df['api'].isin(dll_cols)].shape[0] > 1)\n",
    "    \n",
    "    # 加密信息\n",
    "    crypt_cols = ['CryptAcquireContextW', 'CryptProtectMemory', 'CryptUnprotectMemory', 'CryptHashData',\n",
    "                 'CryptAcquireContextA', 'CryptEncrypt', 'CryptExportKey', 'CryptCreateHash', 'CryptDecodeObjectEx',\n",
    "                 'CryptProtectData', 'CryptDecrypt', 'CryptUnprotectData']\n",
    "    apidict['crypt_info'] = int(df[df['api'].isin(crypt_cols)].shape[0] > 1)\n",
    "    \n",
    "    # 证书信息\n",
    "    cert_cols = ['CertCreateCertificateContext', 'CertOpenSystemStoreA', 'CertOpenSystemStoreW', 'CertOpenStore',\n",
    "                'CertControlStore']\n",
    "    apidict['cert_info'] = int(df[df['api'].isin(cert_cols)].shape[0] > 1)\n",
    "    \n",
    "    # COM信息\n",
    "    com_cols = ['CoCreateInstance', 'CoCreateInstanceEx', 'CoGetClassObject', 'CoInitializeEx', 'CoInitializeSecurity',\n",
    "               'CoUninitialize', 'ControlService']\n",
    "    apidict['com_info'] = int(df[df['api'].isin(com_cols)].shape[0] > 1)\n",
    "    \n",
    "    # Find信息\n",
    "    find_cols = ['FindResourceExW', 'FindResourceA', 'FindFirstFileExW', 'FindWindowA', 'FindResourceW', \n",
    "                'FindWindowW', 'FindResourceExA', 'FindWindowExW', 'FindFirstFileExA', 'FindWindowExA']\n",
    "    apidict['find_info'] = int(df[df['api'].isin(find_cols)].shape[0] > 1)\n",
    "    \n",
    "    # Ldr 信息\n",
    "    ldr_cols  = ['LdrLoadDll', 'LdrGetProcedureAddress', 'LdrUnloadDll', 'LdrGetDllHandle']\n",
    "    apidict['ldr_info'] = int(df[df['api'].isin(ldr_cols)].shape[0] > 1)\n",
    "    apidict['ldr_ratio'] = df['api'].isin(ldr_cols).iloc[-10:].sum() / 10\n",
    "    \n",
    "    # Nt 信息\n",
    "    # TODO\n",
    "\n",
    "    apidict['type_info1'] = apidict['network_info'] * apidict['service_info'] * apidict['reg_info']\n",
    "    apidict['type_info2'] = apidict['ldr_info'] * apidict['file_info']\n",
    "    apidict['type_info3'] = apidict['ldr_info'] * apidict['thread_info'] * apidict['memory_info']\n",
    "    apidict['type_info4'] = apidict['crypt_info'] * apidict['find_info'] * apidict['network_info']\n",
    "    \n",
    "    return apidict\n",
    "\n",
    "# df1 label-0\n",
    "# df2 label-x\n",
    "def fidfeat_augment(id, path, part):\n",
    "    df1 = pd.read_hdf(path[0] + str(id[0]) + '.hdf', part[0])\n",
    "    df2 = pd.read_hdf(path[1] + str(id[1]) + '.hdf', part[1])\n",
    "    \n",
    "    df1_tmp1 = df1.iloc[: int(df1.shape[0]*np.random.uniform(0, 0.2))]\n",
    "    df1_tmp2 = df1.iloc[-int(df1.shape[0]*np.random.uniform(0, 0.2)):]\n",
    "    df = pd.concat([df1_tmp1, df2, df1_tmp2])\n",
    "    \n",
    "    apidict = apidict2.copy()\n",
    "    apidict['file_id'] = id[1]\n",
    "     \n",
    "    for rows in df['api'].value_counts().reset_index().iterrows():\n",
    "        apidict[rows[1]['index']] = rows[1]['api']\n",
    "       \n",
    "    apidict['api_count'] = df['api'].nunique()\n",
    "    apidict['tid_count'] = df['tid'].nunique()\n",
    "    \n",
    "    apidict['return_value_count'] = df['return_value'].nunique()\n",
    "    apidict['return_value=0'] = sum(df['return_value'] == 0) / df.shape[0]\n",
    "    apidict['return_value!=0'] = sum(df['return_value'] != 0) / df.shape[0]\n",
    "    apidict['return_value==1'] = sum(df['return_value'] == 1) / df.shape[0]\n",
    "    apidict['return_value=-1'] = sum(df['return_value'] == -1) / df.shape[0]\n",
    "    apidict['return_value_max'] = df['return_value'].max()\n",
    "    apidict['return_value_min'] = df['return_value'].min()\n",
    "    apidict['return_value_std'] = df['return_value'].std()\n",
    "    \n",
    "    apidict['tid_first_value'] = df.groupby('tid').first()['return_value'].mean()\n",
    "    apidict['tid_first_value!=0'] = sum(df.groupby('tid').first()['return_value'] != 0)\n",
    "    apidict['tid_last_value'] = df.groupby('tid').last()['return_value'].mean()\n",
    "    apidict['tid_last_value!=0'] = sum(df.groupby('tid').last()['return_value'] != 0)\n",
    "    \n",
    "    # Behaviour: File, Process, Memory, Register, Network, Service, Other.\n",
    "    \n",
    "    # 注册表信息，注册表修改信息\n",
    "    reg_cols = ['RegOpenKeyExW', 'RegQueryValueExW', 'RegCloseKey', 'RegOpenKeyExA', 'RegQueryValueExA',\n",
    "               'RegEnumKeyExW', 'RegQueryInfoKeyW', 'RegEnumValueW', 'RegEnumKeyW', 'RegCreateKeyExW',\n",
    "               'RegSetValueExW', 'RegEnumValueA', 'RegDeleteValueW', 'RegCreateKeyExA', 'RegEnumKeyExA',\n",
    "               'RegSetValueExA', 'RegDeleteValueA', 'RegDeleteKeyW', 'RegQueryInfoKeyA', 'RegDeleteKeyA']\n",
    "    \n",
    "    regalter_cols = ['RegCreateKeyExW', 'RegSetValueExW', 'RegDeleteValueW', 'RegCreateKeyExA',\n",
    "               'RegSetValueExA', 'RegDeleteValueA', 'RegDeleteKeyW', 'RegDeleteKeyA']\n",
    "    \n",
    "    apidict['reg_info'] = int(df[df['api'].isin(reg_cols)].shape[0] > 1)\n",
    "    apidict['reg_info_ratio'] = df[df['api'].isin(reg_cols)].shape[0] / (df.shape[0] + 1)\n",
    "    \n",
    "    apidict['reg_infoalter'] = int(df[df['api'].isin(regalter_cols)].shape[0] > 1)\n",
    "    apidict['reg_infoalter_ratio'] = df[df['api'].isin(regalter_cols)].shape[0] / (df[df['api'].isin(reg_cols)].shape[0]+1)\n",
    "    \n",
    "    # 网络信息\n",
    "    network_cols = ['InternetCrackUrlA', 'InternetSetOptionA', 'InternetGetConnectedState', 'InternetOpenW',\n",
    "                   'InternetSetStatusCallback', 'InternetConnectW', 'InternetQueryOptionA', 'InternetCloseHandle',\n",
    "                   'InternetOpenA', 'InternetConnectA', 'InternetOpenUrlA', 'InternetReadFile',\n",
    "                   'InternetGetConnectedStateExW', 'InternetGetConnectedStateExA', 'InternetWriteFile']\n",
    "    apidict['network_info'] = int(df[df['api'].isin(network_cols)].shape[0] > 1)\n",
    "    \n",
    "    # 内存信息\n",
    "    memory_cols = ['NtAllocateVirtualMemory', 'NtFreeVirtualMemory', 'NtProtectVirtualMemory', 'WriteProcessMemory',\n",
    "                  'ReadProcessMemory', 'NtReadVirtualMemory', 'CryptProtectMemory', 'CryptUnprotectMemory', 'NtWriteVirtualMemory']\n",
    "    apidict['memory_info'] = int(df[df['api'].isin(memory_cols)].shape[0] > 1)\n",
    "    \n",
    "    # 文件信息\n",
    "    file_cols = ['NtCreateFile', 'NtWriteFile', 'NtQueryAttributesFile', 'GetFileVersionInfoSizeW', 'GetFileVersionInfoW',\n",
    "                'NtSetInformationFile', 'NtDeviceIoControlFile', 'NtOpenFile', 'FindFirstFileExW', 'GetFileAttributesW',\n",
    "                'DeleteFileW', 'CopyFileA', 'SetFilePointer', 'NtReadFile', 'GetFileType', 'SetFileTime',\n",
    "                'CopyFileW', 'MoveFileWithProgressW', 'CopyFileExW', 'NtDeleteFile']\n",
    "    filealter_cols = ['NtCreateFile', 'NtWriteFile',\n",
    "                'DeleteFileW', 'CopyFileA', 'SetFilePointer', 'SetFileTime',\n",
    "                'CopyFileW', 'MoveFileWithProgressW', 'CopyFileExW', 'NtDeleteFile']\n",
    "    \n",
    "    apidict['file_info'] = int(df[df['api'].isin(file_cols)].shape[0] > 1)\n",
    "    apidict['filealter_info'] = int(df[df['api'].isin(filealter_cols)].shape[0] > 1)\n",
    "    apidict['filealter_ratio'] = apidict['filealter_info'] / (apidict['file_info'] + 1)\n",
    "    \n",
    "    # 进程信息\n",
    "    thread_cols = ['CreateThread', 'Thread32First', 'Thread32Next', 'NtResumeThread', 'NtCreateThreadEx',\n",
    "                   'NtOpenThread', 'NtTerminateThread', 'NtSuspendThread', 'NtGetContextThread'\n",
    "                   'CreateRemoteThread', 'NtQueueApcThread', 'RtlCreateUserThread', 'NtSetContextThread',\n",
    "                   'CreateRemoteThreadEx', 'NtCreateThread']\n",
    "    apidict['thread_info'] = int(df[df['api'].isin(thread_cols)].shape[0] > 1)\n",
    "    apidict['thread_ratio'] = df['api'].isin(thread_cols).iloc[-10:].sum() / 10\n",
    "    \n",
    "    # 服务信息\n",
    "    service_cols = ['OpenServiceA', 'CreateServiceA', 'StartServiceA', 'CreateServiceW', 'StartServiceW',\n",
    "                    'ControlService', 'DeleteService']\n",
    "    apidict['service_info'] = int(df[df['api'].isin(reg_cols)].shape[0] > 1)\n",
    "    \n",
    "    # DLL信息\n",
    "    dll_cols = ['LdrLoadDll', 'LdrUnloadDll', 'LdrGetDllHandle']\n",
    "    apidict['dll_info'] = int(df[df['api'].isin(dll_cols)].shape[0] > 1)\n",
    "    \n",
    "    # 加密信息\n",
    "    crypt_cols = ['CryptAcquireContextW', 'CryptProtectMemory', 'CryptUnprotectMemory', 'CryptHashData',\n",
    "                 'CryptAcquireContextA', 'CryptEncrypt', 'CryptExportKey', 'CryptCreateHash', 'CryptDecodeObjectEx',\n",
    "                 'CryptProtectData', 'CryptDecrypt', 'CryptUnprotectData']\n",
    "    apidict['crypt_info'] = int(df[df['api'].isin(crypt_cols)].shape[0] > 1)\n",
    "    \n",
    "    # 证书信息\n",
    "    cert_cols = ['CertCreateCertificateContext', 'CertOpenSystemStoreA', 'CertOpenSystemStoreW', 'CertOpenStore',\n",
    "                'CertControlStore']\n",
    "    apidict['cert_info'] = int(df[df['api'].isin(cert_cols)].shape[0] > 1)\n",
    "    \n",
    "    # COM信息\n",
    "    com_cols = ['CoCreateInstance', 'CoCreateInstanceEx', 'CoGetClassObject', 'CoInitializeEx', 'CoInitializeSecurity',\n",
    "               'CoUninitialize', 'ControlService']\n",
    "    apidict['com_info'] = int(df[df['api'].isin(com_cols)].shape[0] > 1)\n",
    "    \n",
    "    # Find信息\n",
    "    find_cols = ['FindResourceExW', 'FindResourceA', 'FindFirstFileExW', 'FindWindowA', 'FindResourceW', \n",
    "                'FindWindowW', 'FindResourceExA', 'FindWindowExW', 'FindFirstFileExA', 'FindWindowExA']\n",
    "    apidict['find_info'] = int(df[df['api'].isin(find_cols)].shape[0] > 1)\n",
    "    \n",
    "    # Ldr 信息\n",
    "    ldr_cols  = ['LdrLoadDll', 'LdrGetProcedureAddress', 'LdrUnloadDll', 'LdrGetDllHandle']\n",
    "    apidict['ldr_info'] = int(df[df['api'].isin(ldr_cols)].shape[0] > 1)\n",
    "    apidict['ldr_ratio'] = df['api'].isin(ldr_cols).iloc[-10:].sum() / 10\n",
    "    \n",
    "    # Nt 信息\n",
    "    # TODO\n",
    "\n",
    "    apidict['type_info1'] = apidict['network_info'] * apidict['service_info'] * apidict['reg_info']\n",
    "    apidict['type_info2'] = apidict['ldr_info'] * apidict['file_info']\n",
    "    apidict['type_info3'] = apidict['ldr_info'] * apidict['thread_info'] * apidict['memory_info']\n",
    "    apidict['type_info4'] = apidict['crypt_info'] * apidict['find_info'] * apidict['network_info']\n",
    "    \n",
    "    return apidict\n",
    "    \n",
    "params = {\n",
    "    'learning_rate': 0.05,\n",
    "    'min_child_samples': 10,\n",
    "    'max_depth': -1, \n",
    "    'lambda_l1': 6,\n",
    "    'boosting': 'gbdt', \n",
    "    'objective': 'multiclass', \n",
    "    'metric': 'multi_logloss',\n",
    "    'num_class': 6,\n",
    "    'feature_fraction': .7,\n",
    "    'bagging_fraction': .7,\n",
    "    'seed': 99,\n",
    "    'num_threads': 40,\n",
    "    'verbose': 0\n",
    "}\n",
    "\n",
    "train_loss, val_loss = [], []\n",
    "NFOLD = 6\n",
    "skf = StratifiedKFold(n_splits = NFOLD, random_state = 1, shuffle = True)\n",
    "train_pred = np.zeros((116624, NFOLD))\n",
    "test_pred = np.zeros((53093, NFOLD))\n",
    "\n",
    "# 单个fileid特征\n",
    "# train_feat = Parallel(n_jobs=20)(delayed(fidfeat_single)(i, '../input/train/', 'train') for i in range(116624))\n",
    "# test_feat = Parallel(n_jobs=20)(delayed(fidfeat_single)(i, '../input/test/', 'test') for i in range(53093))\n",
    "\n",
    "for i, (tr_idx, val_idx) in enumerate(skf.split(train_label, train_label['label'])):\n",
    "    print('Fold', i+1)\n",
    "\n",
    "# train_pred /= NFOLD\n",
    "# test_pred /= NFOLD\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-05T14:11:23.338114Z",
     "start_time": "2018-08-05T13:33:02.817479Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "100\n",
      "200\n",
      "300\n",
      "400\n",
      "500\n",
      "600\n",
      "700\n",
      "800\n",
      "900\n",
      "1000\n",
      "1100\n",
      "1200\n",
      "1300\n",
      "1400\n",
      "1500\n",
      "1600\n",
      "1700\n",
      "1800\n",
      "1900\n",
      "2000\n",
      "2100\n",
      "2200\n",
      "2300\n",
      "2400\n",
      "2500\n",
      "2600\n",
      "2700\n",
      "2800\n",
      "2900\n",
      "3000\n",
      "3100\n",
      "3200\n",
      "3300\n",
      "3400\n",
      "3500\n",
      "3600\n",
      "3700\n",
      "3800\n",
      "3900\n",
      "4000\n",
      "4100\n",
      "4200\n",
      "4300\n",
      "4400\n",
      "4500\n",
      "4600\n",
      "4700\n",
      "4800\n",
      "4900\n",
      "5000\n",
      "5100\n",
      "5200\n",
      "5300\n",
      "5400\n",
      "5500\n",
      "5600\n",
      "5700\n",
      "5800\n",
      "5900\n",
      "6000\n",
      "6100\n",
      "6200\n",
      "6300\n",
      "6400\n",
      "6500\n",
      "6600\n",
      "6700\n",
      "6800\n",
      "6900\n",
      "7000\n",
      "7100\n",
      "7200\n",
      "7300\n",
      "7400\n",
      "7500\n",
      "7600\n",
      "7700\n",
      "7800\n",
      "7900\n",
      "8000\n",
      "8100\n",
      "8200\n",
      "8300\n",
      "8400\n",
      "8500\n",
      "8600\n",
      "8700\n",
      "8800\n",
      "8900\n",
      "9000\n",
      "9100\n",
      "9200\n",
      "9300\n",
      "9400\n",
      "9500\n",
      "9600\n",
      "9700\n",
      "9800\n",
      "9900\n",
      "10000\n",
      "10100\n",
      "10200\n",
      "10300\n",
      "10400\n",
      "10500\n",
      "10600\n",
      "10700\n",
      "10800\n",
      "10900\n",
      "11000\n",
      "11100\n",
      "11200\n",
      "11300\n",
      "11400\n",
      "11500\n",
      "11600\n",
      "11700\n",
      "11800\n",
      "11900\n",
      "12000\n",
      "12100\n",
      "12200\n",
      "12300\n",
      "12400\n",
      "12500\n",
      "12600\n",
      "12700\n",
      "12800\n",
      "12900\n",
      "13000\n",
      "13100\n",
      "13200\n",
      "13300\n",
      "13400\n",
      "13500\n",
      "13600\n",
      "13700\n",
      "13800\n",
      "13900\n",
      "14000\n",
      "14100\n",
      "14200\n",
      "14300\n",
      "14400\n",
      "14500\n",
      "14600\n",
      "14700\n",
      "14800\n",
      "14900\n",
      "15000\n",
      "15100\n",
      "15200\n",
      "15300\n",
      "15400\n",
      "15500\n",
      "15600\n",
      "15700\n",
      "15800\n",
      "15900\n",
      "16000\n",
      "16100\n",
      "16200\n",
      "16300\n",
      "16400\n",
      "16500\n",
      "16600\n",
      "16700\n",
      "16800\n",
      "16900\n",
      "17000\n",
      "17100\n",
      "17200\n",
      "17300\n",
      "17400\n",
      "17500\n",
      "17600\n",
      "17700\n",
      "17800\n",
      "17900\n",
      "18000\n",
      "18100\n",
      "18200\n",
      "18300\n",
      "18400\n",
      "18500\n",
      "18600\n",
      "18700\n",
      "18800\n",
      "18900\n",
      "19000\n",
      "19100\n",
      "19200\n",
      "19300\n",
      "19400\n",
      "19500\n",
      "19600\n",
      "19700\n",
      "19800\n",
      "19900\n",
      "20000\n",
      "20100\n",
      "20200\n",
      "20300\n",
      "20400\n",
      "20500\n",
      "20600\n",
      "20700\n",
      "20800\n",
      "20900\n",
      "21000\n",
      "21100\n",
      "21200\n",
      "21300\n",
      "21400\n",
      "21500\n",
      "21600\n",
      "21700\n",
      "21800\n",
      "21900\n",
      "22000\n",
      "22100\n",
      "22200\n",
      "22300\n",
      "22400\n",
      "22500\n",
      "22600\n",
      "22700\n",
      "22800\n",
      "22900\n",
      "23000\n",
      "23100\n",
      "23200\n",
      "23300\n",
      "23400\n",
      "23500\n",
      "23600\n",
      "23700\n",
      "23800\n",
      "23900\n",
      "24000\n",
      "24100\n",
      "24200\n",
      "24300\n",
      "24400\n",
      "24500\n",
      "24600\n",
      "24700\n",
      "24800\n",
      "24900\n",
      "25000\n",
      "25100\n",
      "25200\n",
      "25300\n",
      "25400\n",
      "25500\n",
      "25600\n",
      "25700\n",
      "25800\n",
      "25900\n",
      "26000\n",
      "26100\n",
      "26200\n",
      "26300\n",
      "26400\n",
      "26500\n",
      "26600\n",
      "26700\n",
      "26800\n",
      "26900\n",
      "27000\n",
      "27100\n",
      "27200\n",
      "27300\n",
      "27400\n",
      "27500\n",
      "27600\n",
      "27700\n",
      "27800\n",
      "27900\n",
      "28000\n",
      "28100\n",
      "28200\n",
      "28300\n",
      "28400\n",
      "28500\n",
      "28600\n",
      "28700\n",
      "28800\n",
      "28900\n",
      "29000\n",
      "29100\n",
      "29200\n",
      "29300\n",
      "29400\n",
      "29500\n",
      "29600\n",
      "29700\n",
      "29800\n",
      "29900\n",
      "30000\n",
      "30100\n",
      "30200\n",
      "30300\n",
      "30400\n",
      "30500\n",
      "30600\n",
      "30700\n",
      "30800\n",
      "30900\n",
      "31000\n",
      "31100\n",
      "31200\n",
      "31300\n",
      "31400\n",
      "31500\n",
      "31600\n",
      "31700\n",
      "31800\n",
      "31900\n",
      "32000\n",
      "32100\n",
      "32200\n",
      "32300\n",
      "32400\n",
      "32500\n",
      "32600\n",
      "32700\n",
      "32800\n",
      "32900\n",
      "33000\n",
      "33100\n",
      "33200\n",
      "33300\n",
      "33400\n",
      "33500\n",
      "33600\n",
      "33700\n",
      "33800\n",
      "33900\n",
      "34000\n",
      "34100\n",
      "34200\n",
      "34300\n",
      "34400\n",
      "34500\n",
      "34600\n",
      "34700\n",
      "34800\n",
      "34900\n",
      "35000\n",
      "35100\n",
      "35200\n",
      "35300\n",
      "35400\n",
      "35500\n",
      "35600\n",
      "35700\n",
      "35800\n",
      "35900\n",
      "36000\n",
      "36100\n",
      "36200\n",
      "36300\n",
      "36400\n",
      "36500\n",
      "36600\n",
      "36700\n",
      "36800\n",
      "36900\n",
      "37000\n",
      "37100\n",
      "37200\n",
      "37300\n",
      "37400\n",
      "37500\n",
      "37600\n",
      "37700\n",
      "37800\n",
      "37900\n",
      "38000\n",
      "38100\n",
      "38200\n",
      "38300\n",
      "38400\n",
      "38500\n",
      "38600\n",
      "38700\n",
      "38800\n",
      "38900\n",
      "39000\n",
      "39100\n",
      "39200\n",
      "39300\n",
      "39400\n",
      "39500\n",
      "39600\n",
      "39700\n",
      "39800\n",
      "39900\n",
      "40000\n",
      "40100\n",
      "40200\n",
      "40300\n",
      "40400\n",
      "40500\n",
      "40600\n",
      "40700\n",
      "40800\n",
      "40900\n",
      "41000\n",
      "41100\n",
      "41200\n",
      "41300\n",
      "41400\n",
      "41500\n",
      "41600\n",
      "41700\n",
      "41800\n",
      "41900\n",
      "42000\n",
      "42100\n",
      "42200\n",
      "42300\n",
      "42400\n",
      "42500\n",
      "42600\n",
      "42700\n",
      "42800\n",
      "42900\n",
      "43000\n",
      "43100\n",
      "43200\n",
      "43300\n",
      "43400\n",
      "43500\n",
      "43600\n",
      "43700\n",
      "43800\n",
      "43900\n",
      "44000\n",
      "44100\n",
      "44200\n",
      "44300\n",
      "44400\n",
      "44500\n",
      "44600\n",
      "44700\n",
      "44800\n",
      "44900\n",
      "45000\n",
      "45100\n",
      "45200\n",
      "45300\n",
      "45400\n",
      "45500\n",
      "45600\n",
      "45700\n",
      "45800\n",
      "45900\n",
      "46000\n",
      "46100\n",
      "46200\n",
      "46300\n",
      "46400\n",
      "46500\n",
      "46600\n",
      "46700\n",
      "46800\n",
      "46900\n",
      "47000\n",
      "47100\n",
      "47200\n",
      "47300\n",
      "47400\n",
      "47500\n",
      "47600\n",
      "47700\n",
      "47800\n",
      "47900\n",
      "48000\n",
      "48100\n",
      "48200\n",
      "48300\n",
      "48400\n",
      "48500\n",
      "48600\n",
      "48700\n",
      "48800\n",
      "48900\n",
      "49000\n",
      "49100\n",
      "49200\n",
      "49300\n",
      "49400\n",
      "49500\n",
      "49600\n",
      "49700\n",
      "49800\n",
      "49900\n",
      "50000\n",
      "50100\n",
      "50200\n",
      "50300\n",
      "50400\n",
      "50500\n",
      "50600\n",
      "50700\n",
      "50800\n",
      "50900\n",
      "51000\n",
      "51100\n",
      "51200\n",
      "51300\n",
      "51400\n",
      "51500\n",
      "51600\n",
      "51700\n",
      "51800\n",
      "51900\n",
      "52000\n",
      "52100\n",
      "52200\n",
      "52300\n",
      "52400\n",
      "52500\n",
      "52600\n",
      "52700\n",
      "52800\n",
      "52900\n",
      "53000\n",
      "53100\n",
      "53200\n",
      "53300\n",
      "53400\n",
      "53500\n",
      "53600\n",
      "53700\n",
      "53800\n",
      "53900\n",
      "54000\n",
      "54100\n",
      "54200\n",
      "54300\n",
      "54400\n",
      "54500\n",
      "54600\n",
      "54700\n",
      "54800\n",
      "54900\n",
      "55000\n",
      "55100\n",
      "55200\n",
      "55300\n",
      "55400\n",
      "55500\n",
      "55600\n",
      "55700\n",
      "55800\n",
      "55900\n",
      "56000\n",
      "56100\n",
      "56200\n",
      "56300\n",
      "56400\n",
      "56500\n",
      "56600\n",
      "56700\n",
      "56800\n",
      "56900\n",
      "57000\n",
      "57100\n",
      "57200\n",
      "57300\n",
      "57400\n",
      "57500\n",
      "57600\n",
      "57700\n",
      "57800\n",
      "57900\n",
      "58000\n",
      "58100\n",
      "58200\n",
      "58300\n",
      "58400\n",
      "58500\n",
      "58600\n",
      "58700\n",
      "58800\n",
      "58900\n",
      "59000\n",
      "59100\n",
      "59200\n",
      "59300\n",
      "59400\n",
      "59500\n",
      "59600\n",
      "59700\n",
      "59800\n",
      "59900\n",
      "60000\n",
      "60100\n",
      "60200\n",
      "60300\n",
      "60400\n",
      "60500\n",
      "60600\n",
      "60700\n",
      "60800\n",
      "60900\n",
      "61000\n",
      "61100\n",
      "61200\n",
      "61300\n",
      "61400\n",
      "61500\n",
      "61600\n",
      "61700\n",
      "61800\n",
      "61900\n",
      "62000\n",
      "62100\n",
      "62200\n",
      "62300\n",
      "62400\n",
      "62500\n",
      "62600\n",
      "62700\n",
      "62800\n",
      "62900\n",
      "63000\n",
      "63100\n",
      "63200\n",
      "63300\n",
      "63400\n",
      "63500\n",
      "63600\n",
      "63700\n",
      "63800\n",
      "63900\n",
      "64000\n",
      "64100\n",
      "64200\n",
      "64300\n",
      "64400\n",
      "64500\n",
      "64600\n",
      "64700\n",
      "64800\n",
      "64900\n",
      "65000\n",
      "65100\n",
      "65200\n",
      "65300\n",
      "65400\n",
      "65500\n",
      "65600\n",
      "65700\n",
      "65800\n",
      "65900\n",
      "66000\n",
      "66100\n",
      "66200\n",
      "66300\n",
      "66400\n",
      "66500\n",
      "66600\n",
      "66700\n",
      "66800\n",
      "66900\n",
      "67000\n",
      "67100\n",
      "67200\n",
      "67300\n",
      "67400\n",
      "67500\n",
      "67600\n",
      "67700\n",
      "67800\n",
      "67900\n",
      "68000\n",
      "68100\n",
      "68200\n",
      "68300\n",
      "68400\n",
      "68500\n",
      "68600\n",
      "68700\n",
      "68800\n",
      "68900\n",
      "69000\n",
      "69100\n",
      "69200\n",
      "69300\n",
      "69400\n",
      "69500\n",
      "69600\n",
      "69700\n",
      "69800\n",
      "69900\n",
      "70000\n",
      "70100\n",
      "70200\n",
      "70300\n",
      "70400\n",
      "70500\n",
      "70600\n",
      "70700\n",
      "70800\n",
      "70900\n",
      "71000\n",
      "71100\n",
      "71200\n",
      "71300\n",
      "71400\n",
      "71500\n",
      "71600\n",
      "71700\n",
      "71800\n",
      "71900\n",
      "72000\n",
      "72100\n",
      "72200\n",
      "72300\n",
      "72400\n",
      "72500\n",
      "72600\n",
      "72700\n",
      "72800\n",
      "72900\n",
      "73000\n",
      "73100\n",
      "73200\n",
      "73300\n",
      "73400\n",
      "73500\n",
      "73600\n",
      "73700\n",
      "73800\n",
      "73900\n",
      "74000\n",
      "74100\n",
      "74200\n",
      "74300\n",
      "74400\n",
      "74500\n",
      "74600\n",
      "74700\n",
      "74800\n",
      "74900\n",
      "75000\n",
      "75100\n",
      "75200\n",
      "75300\n",
      "75400\n",
      "75500\n",
      "75600\n",
      "75700\n",
      "75800\n",
      "75900\n",
      "76000\n",
      "76100\n",
      "76200\n",
      "76300\n",
      "76400\n",
      "76500\n",
      "76600\n",
      "76700\n",
      "76800\n",
      "76900\n",
      "77000\n",
      "77100\n",
      "77200\n",
      "77300\n",
      "77400\n",
      "77500\n",
      "77600\n",
      "77700\n",
      "77800\n",
      "77900\n",
      "78000\n",
      "78100\n",
      "78200\n",
      "78300\n",
      "78400\n",
      "78500\n",
      "78600\n",
      "78700\n",
      "78800\n",
      "78900\n",
      "79000\n",
      "79100\n",
      "79200\n",
      "79300\n",
      "79400\n",
      "79500\n",
      "79600\n",
      "79700\n",
      "79800\n",
      "79900\n",
      "80000\n",
      "80100\n",
      "80200\n",
      "80300\n",
      "80400\n",
      "80500\n",
      "80600\n",
      "80700\n",
      "80800\n",
      "80900\n",
      "81000\n",
      "81100\n",
      "81200\n",
      "81300\n",
      "81400\n",
      "81500\n",
      "81600\n",
      "81700\n",
      "81800\n",
      "81900\n",
      "82000\n",
      "82100\n",
      "82200\n",
      "82300\n",
      "82400\n",
      "82500\n",
      "82600\n",
      "82700\n",
      "82800\n",
      "82900\n",
      "83000\n",
      "83100\n",
      "83200\n",
      "83300\n",
      "83400\n",
      "83500\n",
      "83600\n",
      "83700\n",
      "83800\n",
      "83900\n",
      "84000\n",
      "84100\n",
      "84200\n",
      "84300\n",
      "84400\n",
      "84500\n",
      "84600\n",
      "84700\n",
      "84800\n",
      "84900\n",
      "85000\n",
      "85100\n",
      "85200\n",
      "85300\n",
      "85400\n",
      "85500\n",
      "85600\n",
      "85700\n",
      "85800\n",
      "85900\n",
      "86000\n",
      "86100\n",
      "86200\n",
      "86300\n",
      "86400\n",
      "86500\n",
      "86600\n",
      "86700\n",
      "86800\n",
      "86900\n",
      "87000\n",
      "87100\n",
      "87200\n",
      "87300\n",
      "87400\n",
      "87500\n",
      "87600\n",
      "87700\n",
      "87800\n",
      "87900\n",
      "88000\n",
      "88100\n",
      "88200\n",
      "88300\n",
      "88400\n",
      "88500\n",
      "88600\n",
      "88700\n",
      "88800\n",
      "88900\n",
      "89000\n",
      "89100\n",
      "89200\n",
      "89300\n",
      "89400\n",
      "89500\n",
      "89600\n",
      "89700\n",
      "89800\n",
      "89900\n",
      "90000\n",
      "90100\n",
      "90200\n",
      "90300\n",
      "90400\n",
      "90500\n",
      "90600\n",
      "90700\n",
      "90800\n",
      "90900\n",
      "91000\n",
      "91100\n",
      "91200\n",
      "91300\n",
      "91400\n",
      "91500\n",
      "91600\n",
      "91700\n",
      "91800\n",
      "91900\n",
      "92000\n",
      "92100\n",
      "92200\n",
      "92300\n",
      "92400\n",
      "92500\n",
      "92600\n",
      "92700\n",
      "92800\n",
      "92900\n",
      "93000\n",
      "93100\n",
      "93200\n",
      "93300\n",
      "93400\n",
      "93500\n",
      "93600\n",
      "93700\n",
      "93800\n",
      "93900\n",
      "94000\n",
      "94100\n",
      "94200\n",
      "94300\n",
      "94400\n",
      "94500\n",
      "94600\n",
      "94700\n",
      "94800\n",
      "94900\n",
      "95000\n",
      "95100\n",
      "95200\n",
      "95300\n",
      "95400\n",
      "95500\n",
      "95600\n",
      "95700\n",
      "95800\n",
      "95900\n",
      "96000\n",
      "96100\n",
      "96200\n",
      "96300\n",
      "96400\n",
      "96500\n",
      "96600\n",
      "96700\n",
      "96800\n",
      "96900\n",
      "97000\n",
      "97100\n",
      "97200\n",
      "97300\n",
      "97400\n",
      "97500\n",
      "97600\n",
      "97700\n",
      "97800\n",
      "97900\n",
      "98000\n",
      "98100\n",
      "98200\n",
      "98300\n",
      "98400\n",
      "98500\n",
      "98600\n",
      "98700\n",
      "98800\n",
      "98900\n",
      "99000\n",
      "99100\n",
      "99200\n",
      "99300\n",
      "99400\n",
      "99500\n",
      "99600\n",
      "99700\n",
      "99800\n",
      "99900\n",
      "100000\n",
      "100100\n",
      "100200\n",
      "100300\n",
      "100400\n",
      "100500\n",
      "100600\n",
      "100700\n",
      "100800\n",
      "100900\n",
      "101000\n",
      "101100\n",
      "101200\n",
      "101300\n",
      "101400\n",
      "101500\n",
      "101600\n",
      "101700\n",
      "101800\n",
      "101900\n",
      "102000\n",
      "102100\n",
      "102200\n",
      "102300\n",
      "102400\n",
      "102500\n",
      "102600\n",
      "102700\n",
      "102800\n",
      "102900\n",
      "103000\n",
      "103100\n",
      "103200\n",
      "103300\n",
      "103400\n",
      "103500\n",
      "103600\n",
      "103700\n",
      "103800\n",
      "103900\n",
      "104000\n",
      "104100\n",
      "104200\n",
      "104300\n",
      "104400\n",
      "104500\n",
      "104600\n",
      "104700\n",
      "104800\n",
      "104900\n",
      "105000\n",
      "105100\n",
      "105200\n",
      "105300\n",
      "105400\n",
      "105500\n",
      "105600\n",
      "105700\n",
      "105800\n",
      "105900\n",
      "106000\n",
      "106100\n",
      "106200\n",
      "106300\n",
      "106400\n",
      "106500\n",
      "106600\n",
      "106700\n",
      "106800\n",
      "106900\n",
      "107000\n",
      "107100\n",
      "107200\n",
      "107300\n",
      "107400\n",
      "107500\n",
      "107600\n",
      "107700\n",
      "107800\n",
      "107900\n",
      "108000\n",
      "108100\n",
      "108200\n",
      "108300\n",
      "108400\n",
      "108500\n",
      "108600\n",
      "108700\n",
      "108800\n",
      "108900\n",
      "109000\n",
      "109100\n",
      "109200\n",
      "109300\n",
      "109400\n",
      "109500\n",
      "109600\n",
      "109700\n",
      "109800\n",
      "109900\n",
      "110000\n",
      "110100\n",
      "110200\n",
      "110300\n",
      "110400\n",
      "110500\n",
      "110600\n",
      "110700\n",
      "110800\n",
      "110900\n",
      "111000\n",
      "111100\n",
      "111200\n",
      "111300\n",
      "111400\n",
      "111500\n",
      "111600\n",
      "111700\n",
      "111800\n",
      "111900\n",
      "112000\n",
      "112100\n",
      "112200\n",
      "112300\n",
      "112400\n",
      "112500\n",
      "112600\n",
      "112700\n",
      "112800\n",
      "112900\n",
      "113000\n",
      "113100\n",
      "113200\n",
      "113300\n",
      "113400\n",
      "113500\n",
      "113600\n",
      "113700\n",
      "113800\n",
      "113900\n",
      "114000\n",
      "114100\n",
      "114200\n",
      "114300\n",
      "114400\n",
      "114500\n",
      "114600\n",
      "114700\n",
      "114800\n",
      "114900\n",
      "115000\n",
      "115100\n",
      "115200\n",
      "115300\n",
      "115400\n",
      "115500\n",
      "115600\n",
      "115700\n",
      "115800\n",
      "115900\n",
      "116000\n",
      "116100\n",
      "116200\n",
      "116300\n",
      "116400\n",
      "116500\n",
      "116600\n"
     ]
    }
   ],
   "source": [
    "train_feat = Parallel(n_jobs=10)(delayed(fidfeat_single)(i, '../input/train/', 'train') for i in range(116624))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-05T14:59:00.644889Z",
     "start_time": "2018-08-05T14:58:41.891848Z"
    }
   },
   "outputs": [],
   "source": [
    "train_df = pd.DataFrame(train_feat)\n",
    "test_df = pd.DataFrame(test_feat)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-05T14:31:04.434675Z",
     "start_time": "2018-08-05T14:14:17.065206Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "100\n",
      "200\n",
      "300\n",
      "400\n",
      "500\n",
      "600\n",
      "700\n",
      "800\n",
      "900\n",
      "1000\n",
      "1100\n",
      "1200\n",
      "1300\n",
      "1400\n",
      "1500\n",
      "1600\n",
      "1700\n",
      "1800\n",
      "1900\n",
      "2000\n",
      "2100\n",
      "2200\n",
      "2300\n",
      "2400\n",
      "2500\n",
      "2600\n",
      "2700\n",
      "2800\n",
      "2900\n",
      "3000\n",
      "3100\n",
      "3200\n",
      "3300\n",
      "3400\n",
      "3500\n",
      "3600\n",
      "3700\n",
      "3800\n",
      "3900\n",
      "4000\n",
      "4100\n",
      "4200\n",
      "4300\n",
      "4400\n",
      "4500\n",
      "4600\n",
      "4700\n",
      "4800\n",
      "4900\n",
      "5000\n",
      "5100\n",
      "5200\n",
      "5300\n",
      "5400\n",
      "5500\n",
      "5600\n",
      "5700\n",
      "5800\n",
      "5900\n",
      "6000\n",
      "6100\n",
      "6200\n",
      "6300\n",
      "6400\n",
      "6500\n",
      "6600\n",
      "6700\n",
      "6800\n",
      "6900\n",
      "7000\n",
      "7100\n",
      "7200\n",
      "7300\n",
      "7400\n",
      "7500\n",
      "7600\n",
      "7700\n",
      "7800\n",
      "7900\n",
      "8000\n",
      "8100\n",
      "8200\n",
      "8300\n",
      "8400\n",
      "8500\n",
      "8600\n",
      "8700\n",
      "8800\n",
      "8900\n",
      "9000\n",
      "9100\n",
      "9200\n",
      "9300\n",
      "9400\n",
      "9500\n",
      "9600\n",
      "9700\n",
      "9800\n",
      "9900\n",
      "10000\n",
      "10100\n",
      "10200\n",
      "10300\n",
      "10400\n",
      "10500\n",
      "10600\n",
      "10700\n",
      "10800\n",
      "10900\n",
      "11000\n",
      "11100\n",
      "11200\n",
      "11300\n",
      "11400\n",
      "11500\n",
      "11600\n",
      "11700\n",
      "11800\n",
      "11900\n",
      "12000\n",
      "12100\n",
      "12200\n",
      "12300\n",
      "12400\n",
      "12500\n",
      "12600\n",
      "12700\n",
      "12800\n",
      "12900\n",
      "13000\n",
      "13100\n",
      "13200\n",
      "13300\n",
      "13400\n",
      "13500\n",
      "13600\n",
      "13700\n",
      "13800\n",
      "13900\n",
      "14000\n",
      "14100\n",
      "14200\n",
      "14300\n",
      "14400\n",
      "14500\n",
      "14600\n",
      "14700\n",
      "14800\n",
      "14900\n",
      "15000\n",
      "15100\n",
      "15200\n",
      "15300\n",
      "15400\n",
      "15500\n",
      "15600\n",
      "15700\n",
      "15800\n",
      "15900\n",
      "16000\n",
      "16100\n",
      "16200\n",
      "16300\n",
      "16400\n",
      "16500\n",
      "16600\n",
      "16700\n",
      "16800\n",
      "16900\n",
      "17000\n",
      "17100\n",
      "17200\n",
      "17300\n",
      "17400\n",
      "17500\n",
      "17600\n",
      "17700\n",
      "17800\n",
      "17900\n",
      "18000\n",
      "18100\n",
      "18200\n",
      "18300\n",
      "18400\n",
      "18500\n",
      "18600\n",
      "18700\n",
      "18800\n",
      "18900\n",
      "19000\n",
      "19100\n",
      "19200\n",
      "19300\n",
      "19400\n",
      "19500\n",
      "19600\n",
      "19700\n",
      "19800\n",
      "19900\n",
      "20000\n",
      "20100\n",
      "20200\n",
      "20300\n",
      "20400\n",
      "20500\n",
      "20600\n",
      "20700\n",
      "20800\n",
      "20900\n",
      "21000\n",
      "21100\n",
      "21200\n",
      "21300\n",
      "21400\n",
      "21500\n",
      "21600\n",
      "21700\n",
      "21800\n",
      "21900\n",
      "22000\n",
      "22100\n",
      "22200\n",
      "22300\n",
      "22400\n",
      "22500\n",
      "22600\n",
      "22700\n",
      "22800\n",
      "22900\n",
      "23000\n",
      "23100\n",
      "23200\n",
      "23300\n",
      "23400\n",
      "23500\n",
      "23600\n",
      "23700\n",
      "23800\n",
      "23900\n",
      "24000\n",
      "24100\n",
      "24200\n",
      "24300\n",
      "24400\n",
      "24500\n",
      "24600\n",
      "24700\n",
      "24800\n",
      "24900\n",
      "25000\n",
      "25100\n",
      "25200\n",
      "25300\n",
      "25400\n",
      "25500\n",
      "25600\n",
      "25700\n",
      "25800\n",
      "25900\n",
      "26000\n",
      "26100\n",
      "26200\n",
      "26300\n",
      "26400\n",
      "26500\n",
      "26600\n",
      "26700\n",
      "26800\n",
      "26900\n",
      "27000\n",
      "27100\n",
      "27200\n",
      "27300\n",
      "27400\n",
      "27500\n",
      "27600\n",
      "27700\n",
      "27800\n",
      "27900\n",
      "28000\n",
      "28100\n",
      "28200\n",
      "28300\n",
      "28400\n",
      "28500\n",
      "28600\n",
      "28700\n",
      "28800\n",
      "28900\n",
      "29000\n",
      "29100\n",
      "29200\n",
      "29300\n",
      "29400\n",
      "29500\n",
      "29600\n",
      "29700\n",
      "29800\n",
      "29900\n",
      "30000\n",
      "30100\n",
      "30200\n",
      "30300\n",
      "30400\n",
      "30500\n",
      "30600\n",
      "30700\n",
      "30800\n",
      "30900\n",
      "31000\n",
      "31100\n",
      "31200\n",
      "31300\n",
      "31400\n",
      "31500\n",
      "31600\n",
      "31700\n",
      "31800\n",
      "31900\n",
      "32000\n",
      "32100\n",
      "32200\n",
      "32300\n",
      "32400\n",
      "32500\n",
      "32600\n",
      "32700\n",
      "32800\n",
      "32900\n",
      "33000\n",
      "33100\n",
      "33200\n",
      "33300\n",
      "33400\n",
      "33500\n",
      "33600\n",
      "33700\n",
      "33800\n",
      "33900\n",
      "34000\n",
      "34100\n",
      "34200\n",
      "34300\n",
      "34400\n",
      "34500\n",
      "34600\n",
      "34700\n",
      "34800\n",
      "34900\n",
      "35000\n",
      "35100\n",
      "35200\n",
      "35300\n",
      "35400\n",
      "35500\n",
      "35600\n",
      "35700\n",
      "35800\n",
      "35900\n",
      "36000\n",
      "36100\n",
      "36200\n",
      "36300\n",
      "36400\n",
      "36500\n",
      "36600\n",
      "36700\n",
      "36800\n",
      "36900\n",
      "37000\n",
      "37100\n",
      "37200\n",
      "37300\n",
      "37400\n",
      "37500\n",
      "37600\n",
      "37700\n",
      "37800\n",
      "37900\n",
      "38000\n",
      "38100\n",
      "38200\n",
      "38300\n",
      "38400\n",
      "38500\n",
      "38600\n",
      "38700\n",
      "38800\n",
      "38900\n",
      "39000\n",
      "39100\n",
      "39200\n",
      "39300\n",
      "39400\n",
      "39500\n",
      "39600\n",
      "39700\n",
      "39800\n",
      "39900\n",
      "40000\n",
      "40100\n",
      "40200\n",
      "40300\n",
      "40400\n",
      "40500\n",
      "40600\n",
      "40700\n",
      "40800\n",
      "40900\n",
      "41000\n",
      "41100\n",
      "41200\n",
      "41300\n",
      "41400\n",
      "41500\n",
      "41600\n",
      "41700\n",
      "41800\n",
      "41900\n",
      "42000\n",
      "42100\n",
      "42200\n",
      "42300\n",
      "42400\n",
      "42500\n",
      "42600\n",
      "42700\n",
      "42800\n",
      "42900\n",
      "43000\n",
      "43100\n",
      "43200\n",
      "43300\n",
      "43400\n",
      "43500\n",
      "43600\n",
      "43700\n",
      "43800\n",
      "43900\n",
      "44000\n",
      "44100\n",
      "44200\n",
      "44300\n",
      "44400\n",
      "44500\n",
      "44600\n",
      "44700\n",
      "44800\n",
      "44900\n",
      "45000\n",
      "45100\n",
      "45200\n",
      "45300\n",
      "45400\n",
      "45500\n",
      "45600\n",
      "45700\n",
      "45800\n",
      "45900\n",
      "46000\n",
      "46100\n",
      "46200\n",
      "46300\n",
      "46400\n",
      "46500\n",
      "46600\n",
      "46700\n",
      "46800\n",
      "46900\n",
      "47000\n",
      "47100\n",
      "47200\n",
      "47300\n",
      "47400\n",
      "47500\n",
      "47600\n",
      "47700\n",
      "47800\n",
      "47900\n",
      "48000\n",
      "48100\n",
      "48200\n",
      "48300\n",
      "48400\n",
      "48500\n",
      "48600\n",
      "48700\n",
      "48800\n",
      "48900\n",
      "49000\n",
      "49100\n",
      "49200\n",
      "49300\n",
      "49400\n",
      "49500\n",
      "49600\n",
      "49700\n",
      "49800\n",
      "49900\n",
      "50000\n",
      "50100\n",
      "50200\n",
      "50300\n",
      "50400\n",
      "50500\n",
      "50600\n",
      "50700\n",
      "50800\n",
      "50900\n",
      "51000\n",
      "51100\n",
      "51200\n",
      "51300\n",
      "51400\n",
      "51500\n",
      "51600\n",
      "51700\n",
      "51800\n",
      "51900\n",
      "52000\n",
      "52100\n",
      "52200\n",
      "52300\n",
      "52400\n",
      "52500\n",
      "52600\n",
      "52700\n",
      "52800\n",
      "52900\n",
      "53000\n"
     ]
    }
   ],
   "source": [
    "test_feat = Parallel(n_jobs=10)(delayed(fidfeat_single)(i, '../input/test/', 'test') for i in range(53093))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-05T14:59:50.409973Z",
     "start_time": "2018-08-05T14:59:50.388776Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0        True\n",
       "1        True\n",
       "2        True\n",
       "3        True\n",
       "4        True\n",
       "5        True\n",
       "6        True\n",
       "7        True\n",
       "8        True\n",
       "9        True\n",
       "10       True\n",
       "11       True\n",
       "12       True\n",
       "13       True\n",
       "14       True\n",
       "15       True\n",
       "16       True\n",
       "17       True\n",
       "18       True\n",
       "19       True\n",
       "20       True\n",
       "21       True\n",
       "22       True\n",
       "23       True\n",
       "24       True\n",
       "25       True\n",
       "26       True\n",
       "27       True\n",
       "28       True\n",
       "29       True\n",
       "         ... \n",
       "53063    True\n",
       "53064    True\n",
       "53065    True\n",
       "53066    True\n",
       "53067    True\n",
       "53068    True\n",
       "53069    True\n",
       "53070    True\n",
       "53071    True\n",
       "53072    True\n",
       "53073    True\n",
       "53074    True\n",
       "53075    True\n",
       "53076    True\n",
       "53077    True\n",
       "53078    True\n",
       "53079    True\n",
       "53080    True\n",
       "53081    True\n",
       "53082    True\n",
       "53083    True\n",
       "53084    True\n",
       "53085    True\n",
       "53086    True\n",
       "53087    True\n",
       "53088    True\n",
       "53089    True\n",
       "53090    True\n",
       "53091    True\n",
       "53092    True\n",
       "Name: file_id, Length: 53093, dtype: bool"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_df['file_id'] == range(53093)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-05T15:00:29.592355Z",
     "start_time": "2018-08-05T15:00:29.317350Z"
    }
   },
   "outputs": [],
   "source": [
    "import lightgbm as lgb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 175,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-06T01:01:53.356689Z",
     "start_time": "2018-08-06T01:01:45.586707Z"
    },
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "    \n",
    "params = {\n",
    "    'learning_rate': 0.05,\n",
    "    'min_child_samples': 10,\n",
    "    'max_depth': 4, \n",
    "    'boosting': 'gbdt',\n",
    "    'max_bin': 5,\n",
    "    'objective': 'multiclass', \n",
    "    # 'metric': 'multi_logloss',\n",
    "    'num_class': 6,\n",
    "    'feature_fraction': .7,\n",
    "    'bagging_fraction': .7,\n",
    "    'seed': 99,\n",
    "    'num_threads': 10,\n",
    "    'verbose': 0\n",
    "}\n",
    "\n",
    "clf = lgb.train(params, train_set = lgb.Dataset(train_df.drop(['file_id'], axis=1), train_label['label']), \n",
    "                num_boost_round=150)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 176,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-06T01:01:54.120479Z",
     "start_time": "2018-08-06T01:01:53.358371Z"
    },
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "pred = clf.predict(test_df.drop('file_id', axis=1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-05T15:38:33.330999Z",
     "start_time": "2018-08-05T15:38:33.326635Z"
    }
   },
   "outputs": [],
   "source": [
    "pred = pd.DataFrame(pred)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 177,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-06T01:01:55.851274Z",
     "start_time": "2018-08-06T01:01:55.843937Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    51527\n",
       "5     1216\n",
       "3      186\n",
       "1      160\n",
       "2        4\n",
       "Name: 0, dtype: int64"
      ]
     },
     "execution_count": 177,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.DataFrame(np.argmax(pred, axis=1))[0].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-05T15:22:41.363301Z",
     "start_time": "2018-08-05T15:22:41.340156Z"
    }
   },
   "outputs": [],
   "source": [
    "unique, counts = np.unique(pred, return_counts=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-05T15:22:55.658132Z",
     "start_time": "2018-08-05T15:22:55.653787Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([9.12056634e-05, 9.12120163e-05, 9.12132794e-05, ...,\n",
       "       9.96215299e-01, 9.96273720e-01, 9.96849495e-01])"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "unique"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 150,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-05T17:13:55.052202Z",
     "start_time": "2018-08-05T17:11:49.053059Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(97185, 345) (19439, 345)\n",
      "Training until validation scores don't improve for 50 rounds.\n",
      "Early stopping, best iteration is:\n",
      "[142]\ttrain's multi_logloss: 0.00589455\tvalid's multi_logloss: 0.027768\n",
      "0.005894550903284722\n",
      "0.027767990663223083\n",
      "(97186, 345) (19438, 345)\n",
      "Training until validation scores don't improve for 50 rounds.\n",
      "[200]\ttrain's multi_logloss: 0.00387263\tvalid's multi_logloss: 0.0271939\n",
      "Early stopping, best iteration is:\n",
      "[158]\ttrain's multi_logloss: 0.00529796\tvalid's multi_logloss: 0.0268563\n",
      "0.005297955397094447\n",
      "0.02685630853250065\n",
      "(97186, 345) (19438, 345)\n",
      "Training until validation scores don't improve for 50 rounds.\n",
      "[200]\ttrain's multi_logloss: 0.00350763\tvalid's multi_logloss: 0.0272207\n",
      "Early stopping, best iteration is:\n",
      "[162]\ttrain's multi_logloss: 0.00472653\tvalid's multi_logloss: 0.0271004\n",
      "0.004726529407483025\n",
      "0.027100411419432743\n",
      "(97186, 345) (19438, 345)\n",
      "Training until validation scores don't improve for 50 rounds.\n",
      "Early stopping, best iteration is:\n",
      "[141]\ttrain's multi_logloss: 0.00627007\tvalid's multi_logloss: 0.0279271\n",
      "0.006270074400122159\n",
      "0.027927135965804095\n",
      "(97187, 345) (19437, 345)\n",
      "Training until validation scores don't improve for 50 rounds.\n",
      "[200]\ttrain's multi_logloss: 0.00361181\tvalid's multi_logloss: 0.0283932\n",
      "Early stopping, best iteration is:\n",
      "[169]\ttrain's multi_logloss: 0.004627\tvalid's multi_logloss: 0.0281031\n",
      "0.004626999215706761\n",
      "0.02810306078706392\n",
      "(97190, 345) (19434, 345)\n",
      "Training until validation scores don't improve for 50 rounds.\n",
      "Early stopping, best iteration is:\n",
      "[132]\ttrain's multi_logloss: 0.00674841\tvalid's multi_logloss: 0.0279264\n",
      "0.006748413041417935\n",
      "0.027926426030944963\n"
     ]
    }
   ],
   "source": [
    "params = {\n",
    "    'learning_rate': 0.1,\n",
    "    'min_child_samples': 2,\n",
    "    'max_depth': 6, \n",
    "    'boosting': 'gbdt',\n",
    "    # 'max_bin': 5,\n",
    "    'objective': 'multiclass', \n",
    "    'metric': 'multi_logloss',\n",
    "    'num_class': 6,\n",
    "    # 'feature_fraction': .7,\n",
    "#     'bagging_fraction': .7,\n",
    "    'seed': 99,\n",
    "    'num_threads': 10,\n",
    "    'verbose': 0,\n",
    "    'is_training_metric': 'True'\n",
    "}\n",
    "\n",
    "\n",
    "NFOLD = 6\n",
    "skf = StratifiedKFold(n_splits = NFOLD, random_state = 1, shuffle = True)\n",
    "test_pred = np.zeros((53093, 6))\n",
    "\n",
    "for i, (tr_idx, val_idx) in enumerate(skf.split(train_df, train_label['label'])):\n",
    "    tr_x, val_x = train_df.drop(['file_id'], axis=1).iloc[tr_idx], train_df.drop(['file_id'], axis=1).iloc[val_idx]\n",
    "    tr_y, val_y = train_label['label'].iloc[tr_idx].values, train_label['label'].iloc[val_idx].values\n",
    "    \n",
    "    print(tr_x.shape, val_x.shape)\n",
    "    \n",
    "    tr_dataset = lgb.Dataset(tr_x, tr_y)\n",
    "    val_dataset = lgb.Dataset(val_x, val_y)\n",
    "    \n",
    "    clf = lgb.train(params, train_set = tr_dataset, valid_sets= [tr_dataset, val_dataset],\n",
    "                    valid_names = ['train', 'valid'], \n",
    "                verbose_eval=200, early_stopping_rounds=50, num_boost_round=600)\n",
    "    # break\n",
    "    print(log_loss(tr_y, clf.predict(tr_x)))\n",
    "    print(log_loss(val_y, clf.predict(val_x)))\n",
    "    \n",
    "    test_pred += clf.predict(test_df.drop(['file_id'], axis=1))\n",
    "#     gbm.predict(X_test, num_iteration=gbm.best_iteration)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-23T21:15:51.127624Z",
     "start_time": "2018-08-23T21:15:51.104845Z"
    }
   },
   "outputs": [],
   "source": [
    "# 训练集的原始标签\n",
    "train_label = pd.read_csv('../input/train_label.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-23T21:15:51.821376Z",
     "start_time": "2018-08-23T21:15:51.294333Z"
    },
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "train_label2 = pd.concat([train_label[train_label['label'] == 0].sample(frac=0.3), \n",
    "           train_label[train_label['label'] != 0]], axis=0)\n",
    "\n",
    "train_label2.sort_values(by='file_id', inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-23T21:16:09.392927Z",
     "start_time": "2018-08-23T21:16:09.388222Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([     1,      2,      3, ..., 116617, 116621, 116622])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_label2['file_id'].values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-23T21:16:59.146614Z",
     "start_time": "2018-08-23T21:16:59.132097Z"
    },
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "df1 = pd.read_hdf('../input/train/1000.hdf', 'train')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-08-23T21:17:00.169964Z",
     "start_time": "2018-08-23T21:16:59.687935Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>file_id</th>\n",
       "      <th>label</th>\n",
       "      <th>api</th>\n",
       "      <th>tid</th>\n",
       "      <th>return_value</th>\n",
       "      <th>index</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3486072</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>GetSystemTimeAsFileTime</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486073</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>SetUnhandledExceptionFilter</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486074</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>CoInitializeEx</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486075</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>LdrLoadDll</td>\n",
       "      <td>2620</td>\n",
       "      <td>-1073741515</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486076</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>LdrLoadDll</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486077</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtQuerySystemInformation</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486078</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtQueryKey</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486079</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtOpenKeyEx</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486080</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtQueryValueKey</td>\n",
       "      <td>2620</td>\n",
       "      <td>-1073741772</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486081</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtClose</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486082</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtOpenKey</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486083</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtQueryValueKey</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486084</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtClose</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486085</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtOpenKey</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486086</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtQueryValueKey</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486087</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtClose</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486088</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtOpenKey</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486089</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtQueryValueKey</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486090</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtClose</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486091</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtQueryKey</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486092</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtOpenKeyEx</td>\n",
       "      <td>2620</td>\n",
       "      <td>-1073741772</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486093</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>GlobalMemoryStatusEx</td>\n",
       "      <td>2620</td>\n",
       "      <td>1</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486094</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtOpenKey</td>\n",
       "      <td>2620</td>\n",
       "      <td>-1073741772</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486095</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtOpenKey</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486096</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtQueryValueKey</td>\n",
       "      <td>2620</td>\n",
       "      <td>-1073741772</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486097</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtClose</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486098</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtDuplicateObject</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486099</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtCreateThreadEx</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486100</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtDuplicateObject</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486101</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtResumeThread</td>\n",
       "      <td>2620</td>\n",
       "      <td>0</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486144</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>GlobalMemoryStatusEx</td>\n",
       "      <td>2648</td>\n",
       "      <td>1</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486145</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtOpenKey</td>\n",
       "      <td>2648</td>\n",
       "      <td>-1073741772</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486146</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtOpenKey</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486147</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtQueryValueKey</td>\n",
       "      <td>2648</td>\n",
       "      <td>-1073741772</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486148</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtClose</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486149</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtDuplicateObject</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486150</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtCreateThreadEx</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486151</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtDuplicateObject</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486152</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtResumeThread</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486153</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtCreateFile</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486154</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>SetFilePointer</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486155</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtWriteFile</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486156</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtWriteFile</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486157</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtWriteFile</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486158</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtWriteFile</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486159</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtClose</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486160</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>CoUninitialize</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486161</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>LdrGetDllHandle</td>\n",
       "      <td>2648</td>\n",
       "      <td>-1073741515</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486162</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>LdrGetDllHandle</td>\n",
       "      <td>2648</td>\n",
       "      <td>-1073741515</td>\n",
       "      <td>39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486163</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtTerminateProcess</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486164</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtTerminateProcess</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486165</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtClose</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486166</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtClose</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486167</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>LdrUnloadDll</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486168</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtOpenKey</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486169</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtQueryValueKey</td>\n",
       "      <td>2648</td>\n",
       "      <td>-1073741772</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486170</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtClose</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486171</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtClose</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486172</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtClose</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3486173</th>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "      <td>NtTerminateProcess</td>\n",
       "      <td>2648</td>\n",
       "      <td>0</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>102 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         file_id  label                          api   tid  return_value  \\\n",
       "3486072     1000      0      GetSystemTimeAsFileTime  2620             0   \n",
       "3486073     1000      0  SetUnhandledExceptionFilter  2620             0   \n",
       "3486074     1000      0               CoInitializeEx  2620             0   \n",
       "3486075     1000      0                   LdrLoadDll  2620   -1073741515   \n",
       "3486076     1000      0                   LdrLoadDll  2620             0   \n",
       "3486077     1000      0     NtQuerySystemInformation  2620             0   \n",
       "3486078     1000      0                   NtQueryKey  2620             0   \n",
       "3486079     1000      0                  NtOpenKeyEx  2620             0   \n",
       "3486080     1000      0              NtQueryValueKey  2620   -1073741772   \n",
       "3486081     1000      0                      NtClose  2620             0   \n",
       "3486082     1000      0                    NtOpenKey  2620             0   \n",
       "3486083     1000      0              NtQueryValueKey  2620             0   \n",
       "3486084     1000      0                      NtClose  2620             0   \n",
       "3486085     1000      0                    NtOpenKey  2620             0   \n",
       "3486086     1000      0              NtQueryValueKey  2620             0   \n",
       "3486087     1000      0                      NtClose  2620             0   \n",
       "3486088     1000      0                    NtOpenKey  2620             0   \n",
       "3486089     1000      0              NtQueryValueKey  2620             0   \n",
       "3486090     1000      0                      NtClose  2620             0   \n",
       "3486091     1000      0                   NtQueryKey  2620             0   \n",
       "3486092     1000      0                  NtOpenKeyEx  2620   -1073741772   \n",
       "3486093     1000      0         GlobalMemoryStatusEx  2620             1   \n",
       "3486094     1000      0                    NtOpenKey  2620   -1073741772   \n",
       "3486095     1000      0                    NtOpenKey  2620             0   \n",
       "3486096     1000      0              NtQueryValueKey  2620   -1073741772   \n",
       "3486097     1000      0                      NtClose  2620             0   \n",
       "3486098     1000      0            NtDuplicateObject  2620             0   \n",
       "3486099     1000      0             NtCreateThreadEx  2620             0   \n",
       "3486100     1000      0            NtDuplicateObject  2620             0   \n",
       "3486101     1000      0               NtResumeThread  2620             0   \n",
       "...          ...    ...                          ...   ...           ...   \n",
       "3486144     1000      0         GlobalMemoryStatusEx  2648             1   \n",
       "3486145     1000      0                    NtOpenKey  2648   -1073741772   \n",
       "3486146     1000      0                    NtOpenKey  2648             0   \n",
       "3486147     1000      0              NtQueryValueKey  2648   -1073741772   \n",
       "3486148     1000      0                      NtClose  2648             0   \n",
       "3486149     1000      0            NtDuplicateObject  2648             0   \n",
       "3486150     1000      0             NtCreateThreadEx  2648             0   \n",
       "3486151     1000      0            NtDuplicateObject  2648             0   \n",
       "3486152     1000      0               NtResumeThread  2648             0   \n",
       "3486153     1000      0                 NtCreateFile  2648             0   \n",
       "3486154     1000      0               SetFilePointer  2648             0   \n",
       "3486155     1000      0                  NtWriteFile  2648             0   \n",
       "3486156     1000      0                  NtWriteFile  2648             0   \n",
       "3486157     1000      0                  NtWriteFile  2648             0   \n",
       "3486158     1000      0                  NtWriteFile  2648             0   \n",
       "3486159     1000      0                      NtClose  2648             0   \n",
       "3486160     1000      0               CoUninitialize  2648             0   \n",
       "3486161     1000      0              LdrGetDllHandle  2648   -1073741515   \n",
       "3486162     1000      0              LdrGetDllHandle  2648   -1073741515   \n",
       "3486163     1000      0           NtTerminateProcess  2648             0   \n",
       "3486164     1000      0           NtTerminateProcess  2648             0   \n",
       "3486165     1000      0                      NtClose  2648             0   \n",
       "3486166     1000      0                      NtClose  2648             0   \n",
       "3486167     1000      0                 LdrUnloadDll  2648             0   \n",
       "3486168     1000      0                    NtOpenKey  2648             0   \n",
       "3486169     1000      0              NtQueryValueKey  2648   -1073741772   \n",
       "3486170     1000      0                      NtClose  2648             0   \n",
       "3486171     1000      0                      NtClose  2648             0   \n",
       "3486172     1000      0                      NtClose  2648             0   \n",
       "3486173     1000      0           NtTerminateProcess  2648             0   \n",
       "\n",
       "         index  \n",
       "3486072      0  \n",
       "3486073      1  \n",
       "3486074      2  \n",
       "3486075      3  \n",
       "3486076      4  \n",
       "3486077      5  \n",
       "3486078      6  \n",
       "3486079      7  \n",
       "3486080      8  \n",
       "3486081      9  \n",
       "3486082     10  \n",
       "3486083     11  \n",
       "3486084     12  \n",
       "3486085     13  \n",
       "3486086     14  \n",
       "3486087     15  \n",
       "3486088     16  \n",
       "3486089     17  \n",
       "3486090     18  \n",
       "3486091     19  \n",
       "3486092     20  \n",
       "3486093     21  \n",
       "3486094     22  \n",
       "3486095     23  \n",
       "3486096     24  \n",
       "3486097     25  \n",
       "3486098     26  \n",
       "3486099     27  \n",
       "3486100     28  \n",
       "3486101     29  \n",
       "...        ...  \n",
       "3486144     21  \n",
       "3486145     22  \n",
       "3486146     23  \n",
       "3486147     24  \n",
       "3486148     25  \n",
       "3486149     26  \n",
       "3486150     27  \n",
       "3486151     28  \n",
       "3486152     29  \n",
       "3486153     30  \n",
       "3486154     31  \n",
       "3486155     32  \n",
       "3486156     33  \n",
       "3486157     34  \n",
       "3486158     35  \n",
       "3486159     36  \n",
       "3486160     37  \n",
       "3486161     38  \n",
       "3486162     39  \n",
       "3486163     40  \n",
       "3486164     41  \n",
       "3486165     42  \n",
       "3486166     43  \n",
       "3486167     44  \n",
       "3486168     45  \n",
       "3486169     46  \n",
       "3486170     47  \n",
       "3486171     48  \n",
       "3486172     49  \n",
       "3486173     50  \n",
       "\n",
       "[102 rows x 6 columns]"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
